package mode.facadeMode08;

/**
 * 08 外观设计模式
 * https://zhuanlan.zhihu.com/p/629603251
 */
public class FacadePatternDemo {

    public static void main(String[] args) {
        ComputerFacade computer = new ComputerFacade();
        computer.startComputer();
    }

}



// 子系统类
class CPU {
    public void start() {
        System.out.println("CPU: Starting...");
    }
}

class Memory {
    public void load() {
        System.out.println("Memory: Loading...");
    }
}

class HardDrive {
    public void read() {
        System.out.println("Hard Drive: Reading...");
    }
}

// 外观类
class ComputerFacade {
    private CPU cpu;
    private Memory memory;
    private HardDrive hardDrive;

    public ComputerFacade() {
        this.cpu = new CPU();
        this.memory = new Memory();
        this.hardDrive = new HardDrive();
    }

    public void startComputer() {
        cpu.start();
        memory.load();
        hardDrive.read();
        System.out.println("Computer started successfully.");
    }
}
